<?php

include '../../db.php';
$connect = pg_connect($connectionString);
if (!$connect) {
    echo "connect : A connection to the server could not be established!";
    return false;
}

$params = array();
array_push($params, pg_escape_string(strtoupper($_POST["name"])));
array_push($params, pg_escape_string($_POST["ruc"]));
array_push($params, pg_escape_string($_POST["address"]));
array_push($params, pg_escape_string($_POST["contact"]));
array_push($params, pg_escape_string($_POST["phone"]));
array_push($params, pg_escape_string($_POST["ruc"] . " " . strtoupper($_POST["name"])));

$stmt = pg_prepare($connect, "create_sale_client", "INSERT INTO sale_client(name,ruc,address,contact,phone,fullname) VALUES ($1,$2,$3,$4,$5,$6);");
$result = pg_execute($connect, "create_sale_client", $params);

if (!$result) {
    die("Error in SQL query: " . pg_last_error());
}
pg_free_result($result);
pg_close($connect);